package com.snail.starter.mq.controller;

import com.snail.starter.mq.dto.LocalMessageDTO;
import com.snail.starter.mq.holder.MessageHolder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author: snail framework
 * @Date: 2023/7/4 15:16
 * @Version: 1.0.0
 */
@Api(tags = {"消息中间件"})
@RestController
@RequestMapping("/message/test")
public class MessageTestController {

    @Resource
    MessageHolder messageHolder;

    @PostMapping
    @ApiOperation("直接发送消息")
    public boolean send(@RequestBody LocalMessageDTO localMessageDTO) {
        return messageHolder.send(localMessageDTO);
    }

    @PostMapping("/local-message")
    @ApiOperation("本地消息表发送消息")
    public boolean sendByLocalMessage(@RequestBody LocalMessageDTO localMessageDTO) {
        return messageHolder.sendByLocalMessage(localMessageDTO);
    }

}